﻿package mortal.game.view.copy.escort
{
    import Message.Game.*;
    import Message.Public.*;
    import com.gengine.utils.*;
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.scene3D.map3D.*;
    import mortal.game.view.battlefield.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.mainUI.smallMap.view.*;
    import mortal.game.view.task.data.*;
    import mortal.mvc.core.*;

    public class EscortCopyMiniViewBase extends BaseMiniView
    {
        protected var _selectBg:GSprite;
        protected var _todayNum:GTextFiled;
        protected var _escortCar:GTextFiled;
        protected var _num0:BitmapNumberText;
        protected var _num1:BitmapNumberText;
        protected var _num2:BitmapNumberText;
        protected var _num3:BitmapNumberText;
        protected var _num4:BitmapNumberText;
        protected var _tfLeftTime:SecTimerView;
        protected var _taskContent:GTextFiled;
        protected var _submitTaskBtn:GButton;
        protected var _smallMap:SmallMapEmbedView;
        protected var _explain:GTextFiled;
        protected var _taskInfo:TaskInfo;

        public function EscortCopyMiniViewBase()
        {
            return;
        }// end function

        protected function onClickSubmitTaskBtnHandler(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.TaskQuickFinish, this._taskInfo));
            return;
        }// end function

        protected function taskUpdateHandler(param1:Object) : void
        {
            var _loc_3:SPlayerTaskUpdate = null;
            var _loc_2:* = param1 as Array;
            for each (_loc_3 in _loc_2)
            {
                
                if (_loc_3.status == ETaskStatus._ETaskStatusHadComplete || _loc_3.status == ETaskStatus._ETaskStatusHadFail)
                {
                    this._taskInfo = Cache.instance.task.getTaskByCode(_loc_3.taskCode);
                    if (this._taskInfo.stask.group == ETaskGroup._ETaskGroupEscort || this._taskInfo.stask.group == ETaskGroup._ETaskGroupRobEscort)
                    {
                        this.addChild(this._submitTaskBtn);
                    }
                }
            }
            return;
        }// end function

        protected function onEndTaskSuccess(param1:Object) : void
        {
            var _loc_2:* = param1 as TaskInfo;
            if (_loc_2.stask.group == ETaskGroup._ETaskGroupEscort || _loc_2.stask.group == ETaskGroup._ETaskGroupRobEscort)
            {
                DisplayUtil.removeMe(this._taskContent);
                DisplayUtil.removeMe(this._submitTaskBtn);
            }
            return;
        }// end function

        protected function set numTxt(param1:Array) : void
        {
            var _loc_3:BitmapNumberText = null;
            var _loc_2:* = param1.length;
            var _loc_4:int = 0;
            while (_loc_4 < _loc_2)
            {
                
                _loc_3 = this["_num" + _loc_4] as BitmapNumberText;
                _loc_3.text = param1[_loc_4].toString();
                _loc_3.y = 35 + _loc_4 * 25;
                _loc_4++;
            }
            return;
        }// end function

        protected function onExplainLink(event:TextEvent) : void
        {
            return;
        }// end function

        override public function stageResize() : void
        {
            this.x = SceneRange.display.width - 290;
            this.y = 170;
            return;
        }// end function

        override protected function updateView() : void
        {
            super.updateView();
            if (!isDisposed)
            {
                _bg.x = -25;
                _bg.y = -25;
                _bg.width = 278;
                _bg.height = 475;
            }
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            setSize(240, 351);
            this._selectBg = UIFactory.getUICompoment(GSprite, 5, 0, this);
            this._todayNum = UIFactory.gTextField(Language.getStringByParam(70063, 0, 1), 20, 1, 120, 20, this, GlobalStyle.textFormatPutong.center());
            this._escortCar = UIFactory.gTextField("", 67, 33, 140, 130, this, GlobalStyle.textFormatHuang.setLeading(8));
            this._escortCar.multiline = true;
            this._escortCar.wordWrap = true;
            this._escortCar.htmlText = "x<br>x<br>x<br>x<br>x";
            this._num0 = UIFactory.bitmapNumberText(80, 45, "PetGrowYellowNum.png", 18, 21, -6, this, 9);
            this._num1 = UIFactory.bitmapNumberText(80, 45, "PetGrowYellowNum.png", 18, 21, -6, this, 9);
            this._num2 = UIFactory.bitmapNumberText(80, 45, "PetGrowYellowNum.png", 18, 21, -6, this, 9);
            this._num3 = UIFactory.bitmapNumberText(80, 45, "PetGrowYellowNum.png", 18, 21, -6, this, 9);
            this._num4 = UIFactory.bitmapNumberText(80, 45, "PetGrowYellowNum.png", 18, 21, -6, this, 9);
            this._tfLeftTime = UIFactory.secTimeView(Language.getString(70062), 130, 1, 110, 20, this, GlobalStyle.textFormatLv);
            this._taskContent = UIFactory.gTextField("", 5, 160, 230, 20, this);
            this._submitTaskBtn = UIFactory.gButton(Language.getString(35187), 70, 240, 72, 28);
            this._submitTaskBtn.configEventListener(MouseEvent.CLICK, this.onClickSubmitTaskBtnHandler);
            this._smallMap = UIFactory.smallMapEmbedView(ImagesConst.EscortCopyMiniMap, 4, 208, this);
            this._smallMap.run();
            pushUIToDisposeVec(UIFactory.bg(5, 185, 220, 24, this, ImagesConst.RegionTitleBg));
            pushUIToDisposeVec(UIFactory.gTextField(Language.getString(70126), 5, 185, 220, 20, this, GlobalStyle.textFormatPutong.center()));
            this._explain = UIFactory.gTextField("", 5, 185, 50, 20, this);
            this._explain.htmlText = HTMLUtil.addLink(Language.getString(70127), GlobalStyle.colorLv);
            this._explain.configEventListener(TextEvent.LINK, this.onExplainLink);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._todayNum.dispose(param1);
            this._tfLeftTime.dispose(param1);
            this._taskContent.dispose(param1);
            this._submitTaskBtn.dispose(param1);
            this._smallMap.dispose(param1);
            this._explain.dispose(param1);
            this._num0.dispose(param1);
            this._num1.dispose(param1);
            this._num2.dispose(param1);
            this._num3.dispose(param1);
            this._num4.dispose(param1);
            this._escortCar.dispose(param1);
            this._selectBg.dispose(param1);
            this._taskInfo = null;
            this._todayNum = null;
            this._tfLeftTime = null;
            this._taskContent = null;
            this._submitTaskBtn = null;
            this._smallMap = null;
            this._explain = null;
            this._num0 = null;
            this._num1 = null;
            this._num2 = null;
            this._num3 = null;
            this._num4 = null;
            this._selectBg = null;
            this._escortCar = null;
            return;
        }// end function

    }
}
